﻿-- Function: tepuy."table"(character varying,character varying)

-- DROP FUNCTION tepuy."table"(character varying,character varying);

CREATE OR REPLACE FUNCTION tepuy."table"(character varying,character varying)
  RETURNS boolean AS
$BODY$
-- Copyright © 2010 Riztan Gutierrez <riztan at gmail dot com>
-- Esto es parte de: proyecto tepuy.
-- Este programa es Software Libre conforme a la GPL Version 3 o posterior.
-- http://www.gnu.org/licenses/
DECLARE
    ctable varchar;
BEGIN
   select table_name into ctable from information_schema.tables
      where table_schema=$1 and table_name=$2;

   if not found then
      RETURN false;
   end if;

   RETURN true;

END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE
  COST 100;
ALTER FUNCTION tepuy."table"(character varying,character varying) OWNER TO postgres;
COMMENT ON FUNCTION tepuy."table"(character varying,character varying) 
   IS 'retorna verdadero si la tabla existe en el esquema dado';
